package com.hee.erp.modules.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.hee.erp.modules.entity.CarInsureWarnRule;
import com.hee.erp.modules.mapper.CarInsureWarnRuleMapper;
import com.hee.erp.modules.service.ICarInsureWarnRuleService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author weizehong
 * @since 2022-05-02
 */
@Service
@Transactional
public class CarInsureWarnRuleServiceImpl extends ServiceImpl<CarInsureWarnRuleMapper, CarInsureWarnRule> implements ICarInsureWarnRuleService {

    @Override
    public List<CarInsureWarnRule> listByCarId(String carId) {

        LambdaQueryWrapper<CarInsureWarnRule> queryWrapper = new LambdaQueryWrapper<>();
        queryWrapper.eq(CarInsureWarnRule::getCarId, carId);
        List<CarInsureWarnRule> list = this.list(queryWrapper);
        if(list.size() == 0){
            CarInsureWarnRule carInsureWarnRule = new CarInsureWarnRule();
            carInsureWarnRule.setCarId(carId);
            list.add(carInsureWarnRule);
        }
        return list;
    }
}
